<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <style>
                        body {
                                    font-family: Arial, sans-serif;
                                                margin: 20px;
                                                        }
                                                                .container {
                                                                                        margin: 0 auto;
                                                                                                }
                                                                                                        label {
                                                                                                                    display: block;
                                                                                                                                margin-top: 10px;
                                                                                                                                        }
                                                                                                                                                input, select {
                                                                                                                                                            width: 100%;
                                                                                                                                                                        padding: 8px;
                                                                                                                                                                                    margin-top: 5px;
                                                                                                                                                                                            }
                                                                                                                                                                                                    button {
                                                                                                                                                                                                                margin-top: 20px;
                                                                                                                                                                                                                            padding: 10px 20px;
                                                                                                                                                                                                                                        background-color: #007BFF;
                                                                                                                                                                                                                                                    color: white;
                                                                                                                                                                                                                                                                border: none;
                                                                                                                                                                                                                                                                            cursor: pointer;
                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                            button:hover {
                                                                                                                                                                                                                                                                                                        background-color: #0056b3;
                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                        .result {
                                                                                                                                                                                                                                                                                                                                    margin-top: 20px;
                                                                                                                                                                                                                                                                                                                                                font-size: 1.2em;
                                                                                                                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                                                                                                                .signature {
                                                                                                                                                                                                                                                                                                                                                                            position: fixed;
                                                                                                                                                                                                                                                                                                                                                                                        bottom: 10px;
                                                                                                                                                                                                                                                                                                                                                                                                    right: 10px;
                                                                                                                                                                                                                                                                                                                                                                                                                font-size: 14px;
                                                                                                                                                                                                                                                                                                                                                                                                                            color: #888;
                                                                                                                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                                                                                                                        </style>
                                                                                                                                                                                                                                                                                                                                                                                                                                        </head>
                                                                                                                                                                                                                                                                                                                                                                                                                                        <body>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <div class="container">
                                                                                                                                                                                                                                                                                                                                                                                                                                                    <h1>北京出租车价格预估</h1>
                                                                                                                                                                                                                                                                                                                                                                                                                                                            <label for="distance">行驶里程（公里）：</label>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <input type="number" id="distance" step="0.5" min="0" required>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <label for="waitingTime">等候时间（分钟）：</label>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <input type="number" id="waitingTime" step="2.5" min="0" required>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <label for="period">时间段：</label>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <select id="period">
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <option value="normal">普通时段</option>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <option value="peak">早晚高峰（7:00-9:00, 17:00-19:00）</option>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <option value="night">夜间（23:00-次日5:00）</option>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                </select>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <label for="roundTrip">是否往返载客：</label>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <select id="roundTrip">
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <option value="no">否</option>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <option value="yes">是</option>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                </select>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <button onclick="calculatePrice()">计算价格</button>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <div class="result" id="result"></div>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    </div>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <!-- 署名 -->
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <div class="signature">郝师傅</div>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <script>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        function calculatePrice() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    const distance = parseFloat(document.getElementById('distance').value);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                const waitingTime = parseFloat(document.getElementById('waitingTime').value);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            const period = document.getElementById('period').value;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        const roundTrip = document.getElementById('roundTrip').value;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    let basePrice = 13; // 起步价
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                let unitPrice = 2.3; // 基本单价
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            let totalPrice = basePrice;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        // 超过3公里的部分
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    if (distance > 3) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    totalPrice += (distance - 3) * unitPrice;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            // 低速行驶费和等候费
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (period === 'peak') {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        totalPrice += Math.floor(waitingTime / 5) * 2 * unitPrice;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    } else {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    totalPrice += Math.floor(waitingTime / 5) * unitPrice;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            // 空驶费
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (distance > 15 && roundTrip === 'no') {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        totalPrice += (distance - 15) * unitPrice * 0.5;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 夜间收费
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            if (period === 'night') {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            totalPrice *= 1.2;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    // 燃油附加费
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                totalPrice += 1;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            // 四舍五入
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        totalPrice = Math.round(totalPrice);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    document.getElementById('result').innerText = `预估价格：${totalPrice}元`;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               